package com.ff.xyh.consumer.chatroom.config;

import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArraySet;

/**
 * @Auther FF
 * @Date 2022年 12月 04日
 * @Time 17:13
 */

public class UserLock {

    private static final Map<String, UserLock> locks = new HashMap<>();

    public static Map<String, UserLock> getLocks() {
        return locks;
    }

    public UserLock (String userId) {
        locks.put(userId, this);
    }

    public synchronized void waitForConfirm(long timeout) throws InterruptedException {
        this.wait(timeout);
        return ;
    }
    public synchronized void confirmed () {
        this.notify();
    }
}
